package de.baumann.browser.adapter

import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import de.baumann.browser.R


class MortgageTimeAdapter :BaseQuickAdapter<String,BaseViewHolder>(R.layout.item_mortgage_time){

    private var selectPosition = 0

    override fun convert(helper: BaseViewHolder, item: String) {
        val tvMortgageTime:TextView = helper.getView(R.id.tvMortgageTime)
        tvMortgageTime.text = "$item months"
        if (helper.layoutPosition==selectPosition){
            tvMortgageTime.setBackgroundResource(R.drawable.shape_mortgage_time_select)
        }else{
            tvMortgageTime.setBackgroundResource(R.drawable.shape_mortgage_time)
        }

        helper.itemView.setOnClickListener {
            selectPosition = helper.layoutPosition
            notifyDataSetChanged()
        }
    }

    fun getSelectData():Long{
        return getItem(selectPosition)!!.toLong()
    }
}